package enums;

public enum EnumTest  {
    //枚举对象
    RED(1,"RED"),
    BLACK(2,"BLACK"),
    GREEN(3,"GREEN");

    public String color;
    public int ordinal;
    EnumTest(int ordinal,String color) {
        this.color = color;
        this.ordinal = ordinal;
    }

    public static void main(String[] args) {
        //拿到所有枚举类的值
        EnumTest[] enumTest = EnumTest.values();
        for (int i = 0; i < enumTest.length; i++) {
            System.out.println(enumTest[i] + " " + enumTest[i].ordinal);
        }
        System.out.println("=============");
        EnumTest enumTest1 = EnumTest.valueOf("GREEN");
        System.out.println(enumTest1);
    }


    /*public static void main(String[] args) {
        EnumTest enumTest = EnumTest.BLACK;
        switch (enumTest) {
            case RED -> System.out.println("RED");
            case BLACK -> System.out.println("BLACK");
            case GREEN -> System.out.println("GREEN");
        }
    }*/
}
